home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Taifun / Taifun 012 (1987-05-15)(Ossowski, Stefan)(DE)(PD).zip / Taifun 012 (1987-05-15)(Ossowski, Stefan)(DE)(PD).adf / Othello / init.bas < prev    next >
BASIC Source File  |  1987-03-04  |  10KB  |  210 lines

  1. 5     '**** AMIGA OTHELLO ****
  2. 6     ' by David Addison c1986
  3. 7     ' this program is put into the public domain  ENJOY!
  4. 80    goto 860
  5. 90    m=29
  6. 100   ' **** MAIN LOOP ****
  7. 105   on error goto 11000:i=1
  8. 110   if i=1 then rgb 13,15,11,0 else rgb 13,6,9,15
  9. 115   ask mouse x%,y%,b%:if b%=4 and p(1)=0 and p(2)=0 then 1460
  10. 120   if pass=2 then 1850
  11. 130   x1=7*abs(i=2):y1=7*abs(i=1)
  12. 140   x=34+225*abs(i=2):y=101:drawmode 2:box(x,y;x+14,y+7):drawmode 0
  13. 150   for v=64 to 0 step -6:qq=sound(1,1,2,v,3000):qq=sound(2,1,2,v,3000+3000*abs(i=2)):next v
  14. 160   f=0:on p(i)+1 goto 200,440,440
  15. 170   i=i+1:if i<3 then 110
  16. 180   m=m-1:if m<0 then 1850
  17. 190   goto 105
  18. 200   ' **** COMPUTER'S TURN ****
  19. 210   max=0:tempx=0:tempy=0:x1=0
  20. 212   y1=0
  21. 220   if grid(x1,y1) then 270
  22. 230   va=0:d1=-1
  23. 232   d2=-1
  24. 240   on error goto 10260
  25. 250   if grid(x1+d1,y1+d2)=3-i then 280
  26. 260   on error goto 10270:d2=d2+1:if d2<2 then 240
  27. 265   d1=d1+1:if d1<2 then 232
  28. 270   y1=y1+1:if y1<8 then 220
  29. 275   x1=x1+1:if x1<8 then 212
  30. 277   x1=tempx:y1=tempy:f=0:goto 370
  31. 280   a=2
  32. 285   on error goto 10300:temp=grid(x1+d1*a,y1+d2*a):if temp=0 then 260
  33. 290   if temp=i then 310
  34. 300   a=a+1:if a<8 then 285
  35. 305   goto 260
  36. 310   va=va+a
  37. 320   if x1=0 or x1=7 then va=va*4
  38. 330   if y1=0 or y1=7 then va=va*4
  39. 340   if x1=1 or x1=6 or y1=1 or y1=6 then va=va/6
  40. 345   randomize -1
  41. 350   if va>max or (va=max and rnd>0.5) then max=va:tempx=x1:tempy=y1
  42. 360   goto 260
  43. 370   if max=0 then 520
  44. 375   on error goto 11000
  45. 380   destx=wherex((tempy*8)+tempx)+1:desty=wherey((tempy*8)+tempx)+2
  46. 390   drawmode 2:box(x,y;x+14,y+7)
  47. 400   x=x+(abs(destx>x)-abs(destx<x)):y=y+abs(desty>y)-abs(desty<y)
  48. 410   box(x,y;x+14,y+7)
  49. 420   if x=destx and y=desty then drawmode 0:goto 560
  50. 430   goto 390
  51. 440   rem **** HUMAN'S TURN ****
  52. 445   drawmode 2
  53. 450   ask mouse x%,y%,b%:if b%<>4 then 450
  54. 452   if x%>0 and x%<21 and y%>143 and y%<164 then if x1>0 then x1=x1-1:goto 470
  55. 454   if x%>19 and x%<41 and y%>162 and y%<187 then if x1<7 then x1=x1+1:goto 470
  56. 456   if x%>19 and x%<41 and y%>143 and y%<164 then if y1>0 then y1=y1-1:goto 470
  57. 458   if x%>0 and x%<21 and y%>162 and y%<187 then if y1<7 then y1=y1+1:goto 470
  58. 460   if x%>60 and x%<103 and y%>167 and y%<187 then 560
  59. 462   if x%>195 and x%<239 and y%>167 and y%<187 then 520
  60. 463   goto 450
  61. 465   box(x,y;x+14,y+7)
  62. 470   destx=wherex((y1*8)+x1)+1:desty=wherey((y1*8)+x1)+2
  63. 472   box(x,y;x+14,y+7)
  64. 474   x=x+(abs(destx>x)-abs(destx<x)):y=y+abs(desty>y)-abs(desty<y)
  65. 476   box(x,y;x+14,y+7)
  66. 477   if x=destx and y=desty then 490
  67. 480   goto 472
  68. 490   goto 450
  69. 520   box(x,y;x+14,y+7):drawmode 0
  70. 530   sshape(110,87;199,110),temppic%():gshape(110,87),ipass%():pass=pass+1:for v=60 to 0 step -10:for v1=v to 0 step -10
  71. 540   qq=sound(1,1,2,v1,3000):qq=sound(2,1,2,v1,3000+3000*abs(i=2)):next v1:next v:sleep(3*10^6):gshape(110,87),temppic%():goto 800
  72. 550   rem **** FLIP CHIPS ****
  73. 560   if grid(x1,y1) then 840
  74. 570   d1=-1
  75. 575   d2=-1
  76. 580   on error goto 10600
  77. 590   if grid(x1+d1,y1+d2)=3-i then 620
  78. 600   on error goto 10610:d2=d2+1:if d2<2 then 580
  79. 605   d1=d1+1:if d1<2 then 575
  80. 607   if f=0 then 840
  81. 610   goto 800
  82. 620   for a=2 to 7:on error goto 10600:temp=grid(x1+d1*a,y1+d2*a):if temp=0 then 600
  83. 630   if temp=i then 650
  84. 640   next a:goto 600
  85. 650   if f=0 then sc(3-i)=sc(3-i)+1:gosub 720
  86. 660   if pass>0 then pass=pass-1
  87. 670   f=1:for b=1 to a-1
  88. 680   x1=x1+d1:y1=y1+d2:gosub 720
  89. 690   next b:x1=x1-d1*(b-1):y1=y1-d2*(b-1)
  90. 700   goto 600
  91. 710   rem **** PLOT CHIPS ****
  92. 720   drawmode 0
  93. 725   z=pixel(wherex((y1*8)+x1)+5,wherey((y1*8)+x1)+5)
  94. 730   if (z=3 or z=23 or z=7) and i=1 then gg=pip((y1*8)+x1):gosub 20000:goto 770
  95. 750   if (z=3 or z=23 or z=5) and i=2 then gg=pip((y1*8)+x1)+1:gosub 20000
  96. 770   for v=34 to 0 step -6:qq=sound(1,1,2,v,3000):qq=sound(2,1,2,v,3000+3000*abs(i=2)):next v
  97. 780   sc(i)=sc(i)+1:sc(3-i)=sc(3-i)-1:grid(x1,y1)=i:return
  98. 790   rem **** PRINT SCORES + MISC. SUBS ****
  99. 800   pena 0:? at(48,50);inverse(1) "  ":? at(50,48);inverse(1) "  ":pena 18:locate(48,50):? using "##";sc(1):pena 5:locate(50,48):? using "##";sc(1)
  100. 805   pena 0:? at(285,50);inverse(1) "  ":? at(287,48);inverse(1) "  ":pena 18:locate(285,50):? using "##";sc(2)
  101. 806   pena 7:locate(287,48):? using "##";sc(2)
  102. 810   pena 0:? at(64+221*abs(i=2),62);inverse(1) "  ":? at(66+221*abs(i=2),60);inverse(1) "  "
  103. 815   pena 18:locate(64+221*abs(i=2),62):? using "##";m:if i=1 then pena 5 else pena 7
  104. 816   locate(66+221*abs(i=2),60):? using "##";m
  105. 820   if sc(1)=0 or sc(2)=0 then 1850
  106. 830   goto 170
  107. 840   for v=64 to 0 step -1:qq=sound(1,1,2,v,1000):qq=sound(2,1,2,v,1000):next v:goto 450
  108. 850   rem **** INITIALIZATION ****
  109. 860   screen 0,5:drawmode 0:graphic 1
  110. 880   dim grid(7,7),p(2),sc(2),picture%(10000),gold%(700),blue%(700),computer%(200),mouse%(200),ipass%(500),pip(63),wherex(63),wherey(63)
  111. 890   dim pip1%(100),pip2%(100),pip3%(100),pip4%(100),pip5%(100),pip6%(100),pip7%(100),pip8%(100),temppic%(500),start%(300)
  112. 900   dim pip9%(100),pip10%(100),pip11%(100),pip12%(100),pip13%(100),pip14%(100),regsave%(100),sinewave%(11),onewin%(600),twowin%(600),tie%(600)
  113. 1000  bload "othelloscreen",varptr(picture%(0))
  114. 1005  bload "gold",varptr(gold%(0))
  115. 1010  bload "blue",varptr(blue%(0))
  116. 1015  bload "computer",varptr(computer%(0))
  117. 1020  bload "mouse",varptr(mouse%(0))
  118. 1025  bload "ipass",varptr(ipass%(0))
  119. 1030  bload "pip1",varptr(pip1%(0))
  120. 1035  bload "pip2",varptr(pip2%(0))
  121. 1040  bload "pip3",varptr(pip3%(0))
  122. 1045  bload "pip4",varptr(pip4%(0))
  123. 1050  bload "pip5",varptr(pip5%(0))
  124. 1055  bload "pip6",varptr(pip6%(0))
  125. 1060  bload "pip7",varptr(pip7%(0))
  126. 1065  bload "pip8",varptr(pip8%(0))
  127. 1070  bload "pip9",varptr(pip9%(0))
  128. 1075  bload "pip10",varptr(pip10%(0))
  129. 1080  bload "pip11",varptr(pip11%(0))
  130. 1085  bload "pip12",varptr(pip12%(0))
  131. 1090  bload "pip13",varptr(pip13%(0))
  132. 1095  bload "pip14",varptr(pip14%(0))
  133. 1100  bload "othelloscreen_dat",varptr(regsave%(0))
  134. 1105  bload "onewin",varptr(onewin%(0))
  135. 1110  bload "twowin",varptr(twowin%(0))
  136. 1115  bload "tie",varptr(tie%(0))
  137. 1120  bload "start",varptr(start%(0))
  138. 1125  gosub 30000
  139. 1460  rem **** PRE-GAME SETUP ****
  140. 1465  on error goto 11000
  141. 1470  gshape(0,0),picture%()
  142. 1480  restore 1490:for i=0 to 63:read wherex(i):next i
  143. 1490  data 146,162,178,194,210,226,242,258,130,146,162,178,194,210,226,242,114,130,146,162,178,194,210,226,98,114,130,146,162,178,194,210
  144. 1491  data 82,98,114,130,146,162,178,194,66,82,98,114,130,146,162,178,50,66,82,98,114,130,146,162,33,50,66,82,98,114,130,146
  145. 1500  restore 1510:for i=0 to 63:read wherey(i):next i
  146. 1510  data 43,51,59,67,75,83,91,99,51,59,67,75,83,91,99,107,59,67,75,83,91,99,107,115,67,75,83,91,99,107,115,123
  147. 1511  data 75,83,91,99,107,115,123,131,83,91,99,107,115,123,131,139,91,99,107,115,123,131,139,147,99,107,115,123,131,139,147,155
  148. 1530  restore 1540:for i=0 to 63:read pip(i):next i
  149. 1540  data 5,11,13,11,13,11,13,11,7,1,3,1,3,1,3,1,9,3,1,3,1,3,1,3,7,1,3,1,3,1,3,1,9,3,1,3,1,3,1,3,7,1,3,1,3,1,3,1,9,3,1,3,1,3,1,3,7,1,3,1,3,1,3,1
  150. 1550  restore 1560:for i=0 to 11:read sinewave%(i):next i
  151. 1555  audio 15,1:wave 6,sinewave%
  152. 1560  data 100,90,60,100,90,60,-100,-90,-60,-100,-90,-60
  153. 1690  for x=0 to 7:for y=0 to 7:grid(x,y)=0:next y:next x
  154. 1700  grid(4,3)=1:grid(3,4)=1:grid(3,3)=2:grid(4,4)=2
  155. 1702  gshape(146,91),pip2%():gshape(146,107),pip2%():gshape(130,99),pip3%():gshape(162,99),pip3%():rgb 13,9,9,9
  156. 1710  p(1)=1:p(2)=0:sc(1)=2:sc(2)=2:pass=0
  157. 1730  rem **** PLAYER SELECTION ****
  158. 1735  sshape(129,33;180,51),temppic%():gshape(129,33),start%():time=0
  159. 1740  ask mouse x%,y%,b%:time=time+1:if time>3000 then p(1)=0:p(2)=0:gshape(129,33),temppic%():goto 1820
  160. 1742  if b%<>4 then 1740 else time=0
  161. 1745  if x%>4 and x%<88 and y%>31 and y%<62 then gosub 24000
  162. 1750  if x%>221 and x%<298 and y%>31 and y%<62 then gosub 25000
  163. 1755  if x%>128 and x%<180 and y%>32 and y%<52 then gshape(129,33),temppic%():goto 1820
  164. 1760  sleep(0.5*10^6):goto 1740
  165. 1820  gshape(0,28),gold%():gshape(221,28),blue%()
  166. 1840  goto 90
  167. 1850  ' **** GAME OVER ****
  168. 1860  time=0:on error goto 11000
  169. 1870  if sc(1)=sc(2) then gshape(86,90),tie%():rgb 13,9,9,9:goto 1930
  170. 1890  if sc(1)>sc(2) then gshape(86,90),onewin%():rgb 13,15,11,0:goto 1930
  171. 1900  if sc(2)>sc(1) then gshape(86,90),twowin%():rgb 13,6,9,15
  172. 1930  ask mouse x%,y%,b%:time=time+1:if time>3000 then 1940
  173. 1935  if b%<>4 then 1930
  174. 1940  goto 1470
  175. 10260 resume 260
  176. 10270 resume 270
  177. 10300 resume 300
  178. 10600 resume 600
  179. 10610 resume 610
  180. 11000 pena 18:drawmode 0:locate(0,5):? "error # ";err:? "at line ";erl
  181. 11010 rgb 1,0,0,0:rgb 31,12,12,12:system
  182. 20000 h=(y1*8)+x1:on gg goto 20001,20002,20003,20004,20005,20006,20007,20008,20009,20010,20011,20012,20013,20014
  183. 20001 gshape(wherex(h),wherey(h)),pip1%():return
  184. 20002 gshape(wherex(h),wherey(h)),pip2%():return
  185. 20003 gshape(wherex(h),wherey(h)),pip3%():return
  186. 20004 gshape(wherex(h),wherey(h)),pip4%():return
  187. 20005 gshape(wherex(h),wherey(h)),pip5%():return
  188. 20006 gshape(wherex(h),wherey(h)),pip6%():return
  189. 20007 gshape(wherex(h),wherey(h)),pip7%():return
  190. 20008 gshape(wherex(h),wherey(h)),pip8%():return
  191. 20009 gshape(wherex(h),wherey(h)),pip9%():return
  192. 20010 gshape(wherex(h),wherey(h)),pip10%():return
  193. 20011 gshape(wherex(h),wherey(h)),pip11%():return
  194. 20012 gshape(wherex(h),wherey(h)),pip12%():return
  195. 20013 gshape(wherex(h),wherey(h)),pip13%():return
  196. 20014 gshape(wherex(h),wherey(h)),pip14%():return
  197. 24000 p(1)=p(1)+1
  198. 24010 if p(1)>1 then p(1)=0
  199. 24020 if p(1)=0 then gshape(12,51),computer%() else gshape(12,51),mouse%()
  200. 24030 return
  201. 25000 p(2)=p(2)+2
  202. 25010 if p(2)>2 then p(2)=0
  203. 25020 if p(2)=0 then gshape(229,51),computer%() else gshape(229,51),mouse%()
  204. 25030 return
  205. 30000 cnt=0
  206. 30010 for i=0 to 31
  207. 30020 rgb i,regsave%(cnt),regsave%(cnt+1),regsave%(cnt+2):cnt=cnt+3
  208. 30030 next i
  209. 30040 return
  210.